package com.lkd.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lkd.entity.Order;
import com.lkd.entity.OrderMonthCollect;
import com.lkd.mapper.OrderMapper;
import com.lkd.service.OrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-08-20
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {


    //查询指定时间段内的订单数量
    @Override
    public Integer getOrderCount(Date start, Date end) {
        LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<>();
        if (start != null && end != null){
            wrapper.between(Order::getCreateTime,start,end);
        }
        List<Order> orders = getBaseMapper().selectList(wrapper);
        Integer count = orders.size();
        return count;
    }

    @Override
    public Double getOrderAmount(Date start, Date end) {
        Double amount=getBaseMapper().getOrderAmount(start,end);
        return amount;
    }
}
